<?php
    $cnlid = $_GET['id'];
    $channels = array(
            'cctv4k'=>'2000266303',
            'cctv1'=>'2000210103',
    );
    $id = $channels[$cnlid];
        $timestamp = time();
        $appVer = '1.7.0.59666'; // 3.0.8
        $guid = ''; //自己抓自己的guid
        $encryptVer = '4.8.0.00018'; // 8.1
        $platform = '4330303'; // 4330701
        $Key = ($id.$timestamp.$appVer.$guid.$platform); // 加密方法自己在"https://s.yangshipin.cn/txlive/js/txvlive.js"找
        $bstrURL ='https://liveinfo.yangshipin.cn/?cmd=2&cnlid='.$id.'&appVer='.$appVer.'&encryptVer='.$encryptVer.'&platform='.$platform.'&cKey='.$Key;
       
        $UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36';
        //$UA = 'Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)';
        //$UA = '4.8.0.00018';
       
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $bstrURL);                  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_USERAGENT, $UA);
        $data = curl_exec($ch);
        curl_close($ch);
        $json = json_decode($data);
        $vkey = $json->vkey;
        //$url = $json->playurl;
        //$url = $json->backurl_list->url;
        $url = 'http://live-dtocnc-cdn.ysp.cctv.cn/'.$vkey.'/'.$id.'.m3u8';
        header("Content-Type: application/vnd.apple.mpegurl");
        //header('location:'.$url);
        echo $url;
?>